<?php

declare(strict_types=1);

namespace App\Request;

class UserRequest extends BaseRequest
{
    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        $rules = [
            'register' => [
                'account' => [
                    'required',
                    'string',
                    'between:4,20',
                ],
                // 'password' => 'required|string',
                'password' => [
                    'required',
                    'string',
                    'regex:/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@#$%^&+=!])[A-Za-z\d@#$%^&+=!]{12,16}/i',
                ],
                'nickname' => [
                    'required',
                    'string',
                    'between:2,20',
                ],
            ],
            'login' => [
                'account' => [
                    'required',
                    'string',
                    'between:4,20',
                ],
                'password' => 'required|string',
                // 'password' => [
                //     'required',
                //     'string',
                //     'regex:/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@#$%^&+=!])[A-Za-z\d@#$%^&+=!]{12,16}/i',
                // ],
                // 'code' => 'required|string',
                // 'hash_key' => 'required|string',
            ],
            'verify_code' => [
                'curve' => 'string',
                'noise' => 'string',
                'font_color' => 'string',
                'back_color' => 'string',
            ],
            'sub_user_info' => [
                'avatar' => 'string',
                'nickname' => [
                    'string',
                    'between:2,20',
                ],
                'birthday' => 'string',
                'gender' => 'string',
                'city' => 'string',
                // 'province_id' => 'integer',
                // 'city_id' => 'integer',
                'signature' => 'string',
                'wechat' => 'string',
                'qq' => 'string',
                'phone' => 'string',
                'steam' => 'string',
                'official_server_id' => 'string',
                'has_partner_privilege_official' => 'integer',
                'test_server_id' => 'string',
                'has_partner_privilege_test' => 'integer',
            ],
            'sub_platform_info' => [
                'platform_1' => 'required|string',
                'platform_nickname_1' => 'required|string',
                'homepage_link_1' => 'required|string',
                'platform_2' => 'required|string',
                'platform_nickname_2' => 'required|string',
                'homepage_link_2' => 'required|string',
            ],
            'my_wallet' => [
                'category' => 'required|string',
            ],
            'withdrawal' => [
                'amount' => 'required|numeric',
                'alipay_account' => [
                    'required',
                    'string',
                    'between:2,50',
                ],
                'realname' => [
                    'required',
                    'string',
                    'between:2,10',
                ],
            ],
            'my_order' => [
                'order_no' => 'string',
                'status' => 'integer',
            ],
            'sub_user_data' => [
                'file_url' => 'required|string',
                'type' => 'required|string',
                'platform_id' => 'required|integer',
            ],
            'sub_work_order' => [
                'type' => 'required|string',
                'content' => 'required|string',
            ],
        ];
        return $this->useRule($rules);
    }

    public function attributes(): array
    {
        return [
            'account' => '账号',
            'password' => '密码',
            'code' => '验证码',
            'hash_key' => 'HashKey',
            'avatar' => '头像',
            'nickname' => '昵称',
            'birthday' => '生日',
            'gender' => '性别',
            'province_id' => '省份',
            'city_id' => '城市',
            'signature' => '签名',
            'wechat' => '微信',
            'qq' => 'QQ',
            'phone' => '手机号',
            'steam' => 'Steam',
            'official_server_id' => '正式服ID',
            'has_partner_privilege_official' => '合作伙伴权限',
            'test_server_id' => '测试服ID',
            'has_partner_privilege_test' => '合作伙伴权限',
            'platform_1' => '主平台',
            'platform_nickname_1' => '账户昵称',
            'homepage_link_1' => '主页链接',
            'platform_2' => '平台二',
            'platform_nickname_2' => '账户昵称',
            'homepage_link_2' => '主页链接',
            'type' => '类型',
            'file' => '文件',
            'platform_id' => '平台',
            'content' => '工单内容',
        ];
    }
}
